﻿namespace HZY.Framework.Repository.EntityFramework.Attributes;

/// <summary>
/// 实体描述
/// </summary>
[AttributeUsage(AttributeTargets.Class, AllowMultiple = false, Inherited = true)]
public class TableNameAttribute : Attribute
{
    /// <summary>
    /// 命名规则默认 蛇形命名 SysFunction => sys_function
    /// 
    /// <p>如果有 [Table("")] 以他为表名，否则安装规则进行命名</p>
    /// 
    /// </summary>
    public NameRuleType NameRuleType { get; set; } = NameRuleType.SnakeCase;

    /// <summary>
    /// 忽略字段采用命名规则
    /// </summary>
    public NameRuleMode NameRuleMode { get; set; } = NameRuleMode.Default;

    /// <summary>
    /// 实体描述
    /// </summary>
    public TableNameAttribute()
    {
    }

    /// <summary>
    /// 实体描述
    /// </summary>
    /// <param name="nameRuleType"></param>
    public TableNameAttribute(NameRuleType nameRuleType)
    {
        NameRuleType = nameRuleType;
    }
}

/// <summary>
/// 命名规则模式
/// </summary>
public enum NameRuleMode
{
    /// <summary>
    /// 默认 表名 、字段名 采用命名规则
    /// </summary>
    Default = 0,

    /// <summary>
    /// 只有 表名 采用命名规则
    /// </summary>
    TableName = 1,

    /// <summary>
    /// 只有 字段名 采用命名规则
    /// </summary>
    FieldName = 2
}